package team.sun.sss.common.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.sun.sss.common.domain.AjaxResult;
import team.sun.sss.common.domain.TableDataInfo;
import team.sun.sss.common.domain.custom.Custom;
import team.sun.sss.common.entity.StudentEntity;
import team.sun.sss.common.entity.TrainEntity;
import team.sun.sss.common.service.StudentConService;
import team.sun.sss.common.service.TrainService;

import java.util.List;

@Controller
@RequestMapping("common/predicted")
public class PredictedController extends BaseController{

    @Autowired
    private StudentConService studentService;
    @Autowired
    private TrainService trainService;
    @Autowired
    private Custom custom;
    private String baseUrl="predicted/";

    @RequestMapping("/view")
    public String toUpdateFamily(ModelMap mmap) {

        mmap.put("checked",custom.getChecked());
        mmap.put("notChecked",custom.getNotChecked());
        return baseUrl+"predicted";
    }

    /**
     * 查询学生列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StudentEntity studentEntity)
    {

        startPage();
        List<StudentEntity> list = studentService.queryPredicted(studentEntity.getStuName());
        return getDataTable(list);
    }


    /**
     * 查询学生列表
     */

    @PostMapping("/state")
    @ResponseBody
    public AjaxResult status(StudentEntity studentEntity)
    {

        return toAjax(studentService.updateById(studentEntity));
    }


    /**
     * 查询学生列表
     */

    @PostMapping("/status")
    @ResponseBody
    public AjaxResult status(TrainEntity trainEntity)
    {

        return toAjax(trainService.updateById(trainEntity));
    }

}
